﻿using System;
using System.Configuration;
using System.Web.UI;
using mojoPortal.Web.RS.SBM.AppCode.Lib;


namespace mojoPortal.Web.RS.SBM
{
    public partial class RSManageEmployee : RSBasePage
    {
        int _companyid = 0;
        int _employeeid = 0;

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!Page.IsPostBack)
            {
                InitializeReadyServicePage();

                RSUserIdentity userIdentity = GetRSUserIdentity();

                if (RSSBMCommonFunctions.ValidatePermission(userIdentity.RSGroupName, userIdentity.RSPIN))
                {
                    string rsSysAdminPIN = ConfigurationManager.AppSettings["ReadyServiceSysAdminPIN"].ToString();
                    if (userIdentity.RSGroupName == "ADMINISTRATOR" || userIdentity.RSGroupName == "MANAGER" || userIdentity.RSGroupName == "SUPERUSER" || rsSysAdminPIN.Contains(userIdentity.RSPIN))
                    {
                        if (Request.QueryString["action"] == "add")
                            SetRSPageHeader("Add Employee");
                        else
                            SetRSPageHeader("Edit Employee");

                        _companyid = userIdentity.RSCompanyId;

                        if (!String.IsNullOrEmpty(Request.QueryString["employeeid"]))
                            _employeeid = Convert.ToInt32(Request.QueryString["employeeid"].ToString());

                        if (_companyid > 0)
                        {
                            ucEmployeeControl.LoadEmployeeData(_companyid, _employeeid);
                        }
                    }
                }
                else
                {
                    SetRSPageHeader("");
                    lblMessage.Text = "You Do Not Have Permission To View This Page!";
                    pnlEmployees.Visible = false;
                }


            }
        }


    }
}